package com.example.zhihuhelpapp.adapter;

import android.content.Context;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.zhihuhelpapp.R;
import com.example.zhihuhelpapp.bean.AuthorBean;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * 作者列表Adapter
 */
public class AuthorListAdapter extends CommonAdapter<AuthorBean> {
    public AuthorListAdapter(Context context, List<AuthorBean> datas) {
        super(context, R.layout.item_author_list, datas);
    }

    @Override
    protected void convert(ViewHolder holder, AuthorBean authorBean, int position) {
        CircleImageView iv_author_portrait = holder.getView(R.id.iv_author_portrait);
        TextView tv_author_name = holder.getView(R.id.tv_author_name);

        RequestOptions requestOptions = new RequestOptions()
                .placeholder(R.drawable.icon_user_default_portrait)
                .error(R.drawable.icon_user_default_portrait)
                .centerCrop();
        Glide.with(mContext)
                .setDefaultRequestOptions(requestOptions)
                .load(authorBean.getAvatar_url())
                .into(iv_author_portrait);

        tv_author_name.setText(authorBean.getName());
    }
}
